<template>
  <div class="homeAgreementView pd-20">
    <div class="detailView">
      <div class="detail">
        <div class="name">名称</div>
        <div class="value">{{item.name}}</div>
      </div>
      <div class="detail">
        <div class="name">医院</div>
        <div class="value">{{item.hospitalName}}</div>
      </div>
      <div class="detail">
        <div class="name">病种名称</div>
        <div class="value">{{item.diseaseName}}</div>
      </div>
      <div class="detail">
        <div class="name">内容</div>
        <div class="value"
             style="width: 100%">
          <textarea style="width: 100%"
                    rows="20"
                    disabled>{{item.content}}</textarea>
        </div>
      </div>
      <div class="detail">
        <div class="name">创建时间</div>
        <div class="value">{{commonFunction.timeFormat(item.createTime).hasHMS}}</div>
      </div>
      <div class="detail">
        <div class="name">最后修改时间</div>
        <div class="value">{{commonFunction.timeFormat(item.lastUpdateTime).hasHMS}}</div>
      </div>

    </div>
    <div class="operationView">
      <Button type="primary"
              class="operation_btn"
              @click="handleEdit">修改</Button>
      <Button type="primary"
              class="operation_btn"
              @click="handleDel">删除</Button>
      <Button type="primary"
              class="operation_btn"
              @click="handleGoPage">返回</Button>
    </div>
  </div>
</template>

<script>
  export default {
    name: "homeAgreementView",
    data () {
      return {
        item: {}
      }
    },
    mounted () {
      this._getView()
    },
    methods: {
      handleEdit () {
        this.$router.push({ name: 'homeAgreementEdit', query: { id: this.item.id } })
      },
      handleDel () {
        this.$Modal.confirm({
          title: '确认',
          content: '<p>您确认删除该协议？</p>',
          onOk: () => {
            this.ajax({
              type: this.api.homeAgreementDel.type,
              url: this.api.homeAgreementDel.url,
              isDel: true,
              data: { id: this.item.id },
              success: (data) => {
                this.$Message.success(data);
                this.$router.back(-1)
              },
              error: (data) => {
                this.$Message.error(data.message);
              }
            })
          },
          onCancel: () => { }
        });
      },
      handleGoPage () {
        this.$router.push({ name: 'homeAgreementList' })
      },
      _getView () {
        this.ajax({
          type: this.api.homeAgreementView.type,
          url: this.api.homeAgreementView.url,
          data: {
            id: this.$route.query.id
          },
          success: (data) => {
            this.item = data.object
          },
          error: (data) => {
            this.$Message.error(data.message);
          }
        })
      }
    }
  }
</script>

<style lang="scss" type="text/scss" rel="stylesheet/scss">
  .homeAgreementView {
    .detailView .detail .value img {
      width: auto;
    }
  }
</style>
